﻿<Application x:Class="Neurotoxin.Godspeed.Shell.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
             xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
             xmlns:co="clr-namespace:Neurotoxin.Godspeed.Presentation.Converters;assembly=Neurotoxin.Godspeed.Presentation"
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             xmlns:constants="clr-namespace:Neurotoxin.Godspeed.Shell.Constants"
             xmlns:converters="clr-namespace:Neurotoxin.Godspeed.Shell.Converters"
             xmlns:primitives="clr-namespace:Neurotoxin.Godspeed.Shell.Primitives">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Themes/WhistlerBlue.xaml"/>
                <ResourceDictionary>

                    <SolidColorBrush x:Key="ControlBackgroundBrush" Color="#FFD6D6D6" />
                    <SolidColorBrush x:Key="NormalBrush" Color="#FF808080" />
                    <SolidColorBrush x:Key="NormalBorderBrush" Color="#FF9B9999" />
                    <SolidColorBrush x:Key="DefaultedBorderBrush" Color="#FF9BB1C5" />

                    <SolidColorBrush x:Key="MenuGlyphBrush" Color="#FF9BB1C5" />
                    <SolidColorBrush x:Key="MenuHighlight1" Color="#ECEFF5"/>
                    <SolidColorBrush x:Key="MenuHighlight2" Color="#FFD6D6D6"/>

                    <LinearGradientBrush x:Key="Background1" StartPoint="0,0" EndPoint="0,1">
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Color="#F3F3F3" Offset="0" />
                            <GradientStop Color="#EBEBEB" Offset="0.5" />
                            <GradientStop Color="#DDDDDD" Offset="0.5" />
                            <GradientStop Color="#CDCDCD" Offset="1" />
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                    <SolidColorBrush x:Key="Background2" Color="#FF707070" />
                    <LinearGradientBrush x:Key="Background3" StartPoint="0,0" EndPoint="0,1">
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Color="#C4C4C4" Offset="0" />
                            <GradientStop Color="#C4C4C4" Offset="0.75" />
                            <GradientStop Color="#939393" Offset="1" />
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>

                    <co:EnumConverter x:Key="EnumConverter"/>
                    <co:BoolToVisibilityConverter x:Key="BoolToVis"/>
                    <co:NotNullOrEmptyConverter x:Key="NotNullOrEmptyConverter"/>
                    <co:StringFormatter x:Key="StringFormatter"/>
                    <co:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
                    <converters:SizeConverter x:Key="SizeConverter"/>
                    <converters:TitleConverter x:Key="TitleConverter"/>
                    <converters:NameConverter x:Key="NameConverter"/>
                    <converters:ContentTypeConverter x:Key="ContentTypeConverter"/>
					<converters:ResxConverter x:Key="ResxConverter"/>
                    <converters:LocalizedEnumConverter x:Key="LocalizedEnumConverter"/>
                    <converters:PaneHeaderBackgroundConverter x:Key="PaneHeaderBackgroundConverter"
                                                  ActivePaneBrush="{StaticResource DefaultedBorderBrush}"
                                                  InactivePaneBrush="{StaticResource NormalBorderBrush}"/>
                    <constants:ToggleSelectionMode x:Key="Insert">Insert</constants:ToggleSelectionMode>
                    <constants:ToggleSelectionMode x:Key="Space">Space</constants:ToggleSelectionMode>
                    <constants:ToggleSelectionMode x:Key="ShiftDown">ShiftDown</constants:ToggleSelectionMode>
                    <constants:ToggleSelectionMode x:Key="ShiftUp">ShiftUp</constants:ToggleSelectionMode>
                    <system:Boolean x:Key="False">False</system:Boolean>
                    <system:Boolean x:Key="True">True</system:Boolean>

                    <!-- Window -->
                    <Style TargetType="{x:Type primitives:BorderlessWindow}" x:Key="Window">
                        <Setter Property="shell:WindowChrome.WindowChrome">
                            <Setter.Value>
                                <shell:WindowChrome ResizeBorderThickness="6" CaptionHeight="27" CornerRadius="0" GlassFrameThickness="0,0,0,1"/>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type primitives:BorderlessWindow}">
                                    <Border Background="{StaticResource ControlBackgroundBrush}" BorderThickness="1" BorderBrush="{StaticResource NormalBorderBrush}">
                                        <Grid x:Name="Head">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="27" />
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>
                                            
                                            <Image Source="{TemplateBinding Icon}" Width="16" Height="16" Margin="10,3,5,3"/>
                                            <TextBlock Text="{TemplateBinding Title}" Grid.Column="1" VerticalAlignment="Center" Foreground="White" FontWeight="Bold"/>
                                            <TextBlock Text="{TemplateBinding Title}" Grid.Column="1" VerticalAlignment="Center" Margin="-1,-1,1,1" Foreground="{StaticResource NormalBrush}" FontWeight="Bold"/>

                                            <primitives:CaptionButtons Margin="0,0,5,0" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Type="Full"
                                                                     Foreground="{DynamicResource CaptionButtonColor}" FontSize="14" MarginButton="0,0,5,0"
                                                                     VerticalAlignment="Center" shell:WindowChrome.IsHitTestVisibleInChrome="True"/>

                                            <ContentPresenter Margin="7,2,7,7" Grid.Row="1" Grid.ColumnSpan="3" Content="{TemplateBinding Content}"/>
                                        </Grid>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="WindowState" Value="Maximized">
                                            <Setter TargetName="Head" Property="Margin" Value="0,6,2,0"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <!-- Dialog -->
                    <Style TargetType="{x:Type primitives:DialogBase}" x:Key="Dialog">
                        <Setter Property="shell:WindowChrome.WindowChrome">
                            <Setter.Value>
                                <shell:WindowChrome ResizeBorderThickness="0" CaptionHeight="24" CornerRadius="0" GlassFrameThickness="0,0,0,1"/>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="AllowsTransparency" Value="True"/>
                        <Setter Property="WindowStyle" Value="None"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type primitives:DialogBase}">
                                    <AdornerDecorator>
                                        <Border Background="{StaticResource ControlBackgroundBrush}" BorderThickness="1" BorderBrush="{StaticResource NormalBorderBrush}" Margin="5">
                                            <Border.Effect>
                                                <DropShadowEffect ShadowDepth="6" Direction="315" Opacity="0.35" BlurRadius="0"/>
                                            </Border.Effect>
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto"/>
                                                    <ColumnDefinition Width="*"/>
                                                    <ColumnDefinition Width="Auto"/>
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="24" />
                                                    <RowDefinition Height="*"/>
                                                </Grid.RowDefinitions>

                                                <Image Source="{TemplateBinding Icon}" Width="16" Height="16" Margin="7,3,5,3" Visibility="{TemplateBinding IconVisibility}"/>
                                                <TextBlock Text="{TemplateBinding Title}" Grid.Column="1" VerticalAlignment="Center" Foreground="White" FontWeight="Bold"/>
                                                <TextBlock Text="{TemplateBinding Title}" Grid.Column="1" VerticalAlignment="Center" Margin="-1,-1,1,1" Foreground="{StaticResource NormalBrush}" FontWeight="Bold"/>

                                                <primitives:CaptionButtons Margin="0,0,5,0" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Type="Close"
                                                                         Foreground="{DynamicResource CaptionButtonColor}" FontSize="14" MarginButton="0,0,5,0"
                                                                         VerticalAlignment="Center" shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                                                         Visibility="{TemplateBinding CloseButtonVisibility}"/>

                                                <ContentPresenter Margin="5" Grid.Row="1" Grid.ColumnSpan="3" Content="{TemplateBinding Content}"/>
                                            </Grid>
                                        </Border>
                                    </AdornerDecorator>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                    
                    <!-- Link -->
                    <Style TargetType="{x:Type TextBlock}" x:Key="Link">
                        <Setter Property="Foreground" Value="Blue"/>
                    </Style>

                    <Style TargetType="Separator" x:Key="SeparatorStyle">
                        <Setter Property="Height" Value="1"/>
                        <Setter Property="Margin" Value="0,4,0,4"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Separator">
                                    <Border BorderBrush="{StaticResource NormalBorderBrush}" BorderThickness="1"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <!-- TopLevelHeader -->
                    <ControlTemplate TargetType="MenuItem" x:Key="TopLevelHeaderTemplate">
                        <Grid SnapsToDevicePixels="true">
                            <Rectangle Name="OuterBorder" RadiusX="2" RadiusY="2" />
                            <Rectangle Name="Bg" Margin="1" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="1" RadiusY="1" />
                            <Rectangle Name="InnerBorder" Margin="2" />
                            <DockPanel>
                                <ContentPresenter Name="Icon" Margin="4,0,6,0" VerticalAlignment="Center" ContentSource="Icon" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                <!--<Path Name="GlyphPanel" Margin="7,0,0,0" Visibility="Collapsed" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Data="{StaticResource [0] Ñ}" />-->
                                <ContentPresenter ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </DockPanel>
                            <Popup Name="PART_Popup" HorizontalOffset="1" VerticalOffset="-1" AllowsTransparency="true" Placement="Bottom" 
                                   Focusable="false" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimation}}" 
                                   IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
                                   MaxHeight="300">
                                <Popup.Resources>
                                    <ResourceDictionary Source="/Themes/FloatingScrollBar.xaml"/>
                                </Popup.Resources>
                                <theme:SystemDropShadowChrome Name="Shdw" Color="Transparent" FlowDirection="LeftToRight">
                                    <Border Name="SubMenuBorder" Background="White" BorderBrush="{StaticResource NormalBorderBrush}" BorderThickness="1">
                                        <ScrollViewer Name="SubMenuScrollViewer" Margin="1,0">
                                            <Grid>
                                                <ItemsPresenter Name="ItemsPresenter" Margin="2" KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Cycle" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.IsSharedSizeScope="true" />
                                            </Grid>
                                        </ScrollViewer>
                                    </Border>
                                </theme:SystemDropShadowChrome>
                            </Popup>
                        </Grid>
                        <!--<ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">-->
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                                <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
                            </Trigger>
                            <Trigger Value="{x:Null}" Property="Icon">
                                <Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
                            </Trigger>
                            <Trigger Property="IsChecked" Value="true">
                                <!--<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />-->
                                <Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
                            </Trigger>
                            <Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="true">
                                <Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5" />
                                <Setter TargetName="Shdw" Property="Color" Value="#71000000" />
                            </Trigger>
                            <Trigger Property="IsHighlighted" Value="true">
                                <Setter TargetName="Bg" Property="Stroke" Value="#90717070" />
                                <Setter TargetName="OuterBorder" Property="Stroke" Value="#50FFFFFF" />
                                <Setter TargetName="InnerBorder" Property="Stroke" Value="#50FFFFFF" />
                            </Trigger>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter TargetName="Bg" Property="Stroke" Value="#E0717070" />
                                <Setter TargetName="Bg" Value="{StaticResource Background3}" Property="Fill" />
                                <Setter TargetName="InnerBorder" Property="Stroke" Value="#50747272" />
                            </Trigger>
                            <Trigger Property="IsSubmenuOpen" Value="true">
                                <Setter TargetName="Bg" Property="Stroke" Value="#E0717070" />
                                <Setter TargetName="Bg" Value="{StaticResource Background3}" Property="Fill" />
                                <Setter TargetName="InnerBorder" Property="Stroke" Value="#50747272" />
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="#FF9A9A9A" />
                                <!--<Setter TargetName="GlyphPanel" Property="Fill" Value="#848589" />-->
                            </Trigger>
                            <!--<Trigger SourceName="SubMenuScrollViewer" Property="CanContentScroll" Value="false">
                                <Setter TargetName="OpaqueRect" Value="{Binding ElementName=SubMenuScrollViewer, Path=VerticalOffset}" Property="Top" />
                                <Setter TargetName="OpaqueRect" Value="{Binding ElementName=SubMenuScrollViewer, Path=HorizontalOffset}" Property="Left" />
                            </Trigger>-->
                        </ControlTemplate.Triggers>
                    </ControlTemplate>

                    <!-- TopLevelItem -->
                    <ControlTemplate TargetType="MenuItem" x:Key="TopLevelItemTemplate">
                        <Border Name="Border">
                            <Grid>
                                <ContentPresenter Margin="6,3,6,3" ContentSource="Header" RecognizesAccessKey="True" />
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsHighlighted" Value="true">
                                <Setter TargetName="Border" Property="Background" Value="{StaticResource NormalBrush}"/>
                                <Setter TargetName="Border" Property="BorderBrush" Value="Transparent"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>

                    <!-- SubmenuItem -->
                    <ControlTemplate TargetType="MenuItem" x:Key="SubmenuItemTemplate">
                        <Border Name="Border">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="10"/>
                                </Grid.ColumnDefinitions>
                                <ContentPresenter Name="Icon" Margin="6,0,6,0" VerticalAlignment="Center" ContentSource="Icon"/>
                                <Border Name="Check" Width="13" Height="13" Visibility="Collapsed" Margin="6,0,6,0" Background="{StaticResource NormalBrush}" BorderThickness="1" BorderBrush="{StaticResource NormalBorderBrush}">
                                    <Path Name="CheckMark" Width="7" Height="7" Visibility="Hidden" SnapsToDevicePixels="False" Stroke="{StaticResource MenuGlyphBrush}" StrokeThickness="2" Data="M 0 0 L 7 7 M 0 7 L 7 0" />
                                </Border>
                                <ContentPresenter Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" VerticalAlignment="Center" Margin="0,2,0,2"/>
                                <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="15,2,0,2" VerticalAlignment="Center" />
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="Icon" Value="{x:Null}">
                                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
                            </Trigger>
                            <Trigger Property="IsChecked" Value="true">
                                <Setter TargetName="CheckMark" Property="Visibility" Value="Visible"/>
                            </Trigger>
                            <Trigger Property="IsCheckable" Value="true">
                                <Setter TargetName="Check" Property="Visibility" Value="Visible"/>
                                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
                            </Trigger>
                            <Trigger Property="IsHighlighted" Value="true">
                                <Setter TargetName="Border" Property="Background" Value="{StaticResource MenuHighlight2}"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
                            </Trigger>
                            <Trigger Property="Command" Value="{x:Null}">
                                <Setter Property="IsEnabled" Value="False"/>
                            </Trigger>
                            <Trigger Property="InputGestureText" Value="">
                                <Setter TargetName="InputGestureText" Property="Visibility" Value="Collapsed"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>

                    <!-- FileSystemItemTitleTemplate -->

                    <DataTemplate x:Key="FileSystemItemTitleTemplate">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding Thumbnail}" Width="16" Height="16" Margin="2,0,3,0" SnapsToDevicePixels="True"
                                   RenderOptions.BitmapScalingMode="NearestNeighbor"/>
                            <TextBlock FontWeight="Bold" x:Name="Primary">
                                    <TextBlock.Text>
                                        <MultiBinding Converter="{StaticResource TitleConverter}">
                                            <Binding Path="Title" />
                                            <Binding Path="Name" />
                                            <Binding Path="Type" />
                                        </MultiBinding>
                                    </TextBlock.Text>
                            </TextBlock>
                            <Image Source="/Resources/fileaccesserror.png" Width="11" Height="16" Margin="0" 
                                        Visibility="{Binding IsLocked, Converter={StaticResource BoolToVis}, FallbackValue=Collapsed}"
                                        ToolTip="{Binding LockMessage}" />
                            <TextBlock Opacity="0.4" x:Name="Secondary">
                                    <TextBlock.Text>
                                        <MultiBinding Converter="{StaticResource NameConverter}">
                                            <Binding Path="Title" />
                                            <Binding Path="Name" />
                                        </MultiBinding>
                                    </TextBlock.Text>
                            </TextBlock>
                        </StackPanel>
                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                                <Setter TargetName="Primary" Property="Foreground" Value="Red" />
                                <Setter TargetName="Secondary" Property="Foreground" Value="Red" />
                            </DataTrigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>        
        
    </Application.Resources>
</Application>